package com.dragon.repository.domain.dto;

import com.baomidou.mybatisplus.annotation.TableField;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.Project;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonInclude;

import java.util.ArrayList;
import java.util.List;
import java.util.Date;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ProjectDTO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "项目id")
    private Integer id;

    @ApiModelProperty(value = "客户id")
    private Integer customerId;

    @ApiModelProperty(value = "用户id")
    private Integer adminId;

    @ApiModelProperty(value = "部门id")
    private Integer departmentId;

    @ApiModelProperty(value = "项目名称")
    private String name;

    @ApiModelProperty(value = "项目内容")
    private String remark;

    @ApiModelProperty(value = "项目审核：0未审核 1通过 2未通过 3审核中")
    private Integer audit;

    @ApiModelProperty(value = "审核人id")
    private Integer auditId;

    @ApiModelProperty(value = "审核原因")
    private String cause;

    @ApiModelProperty(value = "项目流程状态")
    private String processStatus;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @ApiModelProperty(value = "修改时间")
    private Date updateTime;

    @ApiModelProperty(value = "项目截至时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date endTime;

    @ApiModelProperty(value = "审核时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date auditTime;


    @ApiModelProperty(value = "客户名称")
    @TableField(exist = false)
    private String customerName;


    public ProjectDTO() {}

    public ProjectDTO(Project entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static ProjectDTO convert(Project entity) {
        return new ProjectDTO(entity);
    }

    public static List<ProjectDTO> convertList(List<Project> list) {
        List<ProjectDTO> resultList = new ArrayList<>();
        for (Project entity : list) {
            resultList.add(new ProjectDTO(entity));
        }
        return resultList;
    }}
